﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Model;
using DAL;

public partial class Student_Login : System.Web.UI.Page
{
    private StudentManager studentManager;

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
    {
        this.studentManager = new StudentManager();

        

        string userType = "Student"; //用户类型
        string userId = txtUserId.Value; //用户Id
        string password = txtPassword.Value; //密码


        if (userId.Trim().Equals("") || password.Trim().Equals(""))
        {
            msg.Text = "不能为空";
            return;
        }

        string id;
        Student student = new Student(userId, password);

        id = studentManager.LoginReturnId(student);//登陆


        if (id != null)
        {
            Session["userType"] = userType;   //  把用户类型和id保存到session中
            Session["id"] = id;
            Session["name"] = userId;

            Response.Redirect("Default.aspx");
        }
        else
        {
            msg.Text += "登陆失败！";
        }
    }
}
